using TireService.Data;
using System.Collections.Generic;
using System.Linq;
using System;

namespace TireService.Web.Reports.Design
{
    partial class TireSetLabels
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        public TireSetLabels(int ContainerCargoRoomId)
        {
            this.InitializeComponent();

            // Bind label data to report
            TireServiceDB db = new TireServiceDB();
            ContainerCargoRoomTireSetView cargoroom = db.ContainerCargoRoomTireSetViews.SingleOrDefault(p => p.ContainerCargoRoomId == ContainerCargoRoomId);

            if (cargoroom == null)
            {
                // No cargoroom was found and labels can not be generated
            }
            else
            {
                // Add tireset labels
                ContainerCargoRoomLabels labels = new ContainerCargoRoomLabels(cargoroom.CargoRoomNumber.ToString(), cargoroom.ContainerNumber, Convert.ToInt32(cargoroom.CustomerId), Convert.ToInt32(cargoroom.CarId), Convert.ToInt32(cargoroom.TireSetId));
                labels.CreateDocument();
                this.Pages.AddRange(labels.Pages);

                if (cargoroom.HubCaps == true)
                {
                    // Add extra report with label for hubcaps
                    ContainerCargoRoomHubCapsLabel hubcaplabel = new ContainerCargoRoomHubCapsLabel(cargoroom.CargoRoomNumber.ToString(), cargoroom.ContainerNumber);
                    hubcaplabel.CreateDocument();
                    this.Pages.AddRange(hubcaplabel.Pages);

                }
            }

            db.Dispose();
        }

        public TireSetLabels(List<int> ContainerCargoRoomId)
        {
            this.InitializeComponent();

            // Bind label data to report
            TireServiceDB db = new TireServiceDB();

            foreach (int cargoroomid in ContainerCargoRoomId)
            {
                ContainerCargoRoomTireSetView cargoroom = db.ContainerCargoRoomTireSetViews.SingleOrDefault(p => p.ContainerCargoRoomId == cargoroomid);

                if (cargoroom == null)
                {
                    // No cargoroom was found and labels can not be generated
                }
                else
                {
                    // Add tireset labels
                    ContainerCargoRoomLabels labels = new ContainerCargoRoomLabels(cargoroom.CargoRoomNumber.ToString(), cargoroom.ContainerNumber, Convert.ToInt32(cargoroom.CustomerId), Convert.ToInt32(cargoroom.CarId), Convert.ToInt32(cargoroom.TireSetId));
                    labels.CreateDocument();
                    this.Pages.AddRange(labels.Pages);

                    if (cargoroom.HubCaps == true)
                    {
                        // Add extra report with label for hubcaps
                        ContainerCargoRoomHubCapsLabel hubcaplabel = new ContainerCargoRoomHubCapsLabel(cargoroom.CargoRoomNumber.ToString(), cargoroom.ContainerNumber);
                        hubcaplabel.CreateDocument();
                        this.Pages.AddRange(hubcaplabel.Pages);

                    }
                }    
            }

            db.Dispose();
        }

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.Detail = new DevExpress.XtraReports.UI.DetailBand();
            this.TopMargin = new DevExpress.XtraReports.UI.TopMarginBand();
            this.BottomMargin = new DevExpress.XtraReports.UI.BottomMarginBand();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
            // 
            // Detail
            // 
            this.Detail.HeightF = 478.125F;
            this.Detail.Name = "Detail";
            this.Detail.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
            this.Detail.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            // 
            // TopMargin
            // 
            this.TopMargin.HeightF = 0F;
            this.TopMargin.Name = "TopMargin";
            this.TopMargin.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
            this.TopMargin.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            // 
            // BottomMargin
            // 
            this.BottomMargin.HeightF = 0F;
            this.BottomMargin.Name = "BottomMargin";
            this.BottomMargin.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
            this.BottomMargin.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            // 
            // TireSetLabels
            // 
            this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
            this.Detail,
            this.TopMargin,
            this.BottomMargin});
            this.Landscape = true;
            this.Margins = new System.Drawing.Printing.Margins(100, 100, 0, 0);
            this.PageHeight = 827;
            this.PageWidth = 1169;
            this.PaperKind = System.Drawing.Printing.PaperKind.A4;
            this.Version = "10.2";
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();

        }

        #endregion

        private DevExpress.XtraReports.UI.DetailBand Detail;
        private DevExpress.XtraReports.UI.TopMarginBand TopMargin;
        private DevExpress.XtraReports.UI.BottomMarginBand BottomMargin;
    }
}
